package com.aw.baselib.util.update

import com.aw.baselib.util.AwLog
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import java.util.concurrent.TimeUnit

/**
 * Created by hzw
 */
object Okhttp3Manager {
    val okhttp: OkHttpClient.Builder
        get() {
            val logging = HttpLoggingInterceptor { message: String? -> AwLog.d("okhttp", message) }
            logging.level = HttpLoggingInterceptor.Level.BODY
            val httpClient = OkHttpClient.Builder()
            httpClient.connectTimeout(1, TimeUnit.MINUTES)
            httpClient.readTimeout(1, TimeUnit.MINUTES)
            httpClient.writeTimeout(1, TimeUnit.MINUTES)
            //        httpClient.retryOnConnectionFailure(true);
            httpClient.addInterceptor(logging)
            //加入拦截器
            //        RequestParamInterceptor requestParamInterceptor = new RequestParamInterceptor();
            //        httpClient.addNetworkInterceptor(requestParamInterceptor);
            //加入https的证书
            /*      int[] certficates = new int[]{R.raw.app_key};
        SSLSocketFactory sslSocketFactory = getSSLSocketFactory(AppContext.getContext(), certficates);
        if (sslSocketFactory != null) {
            httpClient.sslSocketFactory(sslSocketFactory);
        }
*/return httpClient
        }
}